package com.hzjob.dao;

import java.util.List;

import javax.transaction.Transaction;

import org.hibernate.Query;
import org.hibernate.Session;

import com.hzjob.domain.TCompany;
import com.hzjob.util.MySessionFactory;

public class CompanyDaoImpl implements CompanyDao {

	@Override
	public TCompany findCompanyById(Integer id) {
		Session session = MySessionFactory.currentSession(1);
		session.beginTransaction();
		TCompany company = (TCompany) session.load(TCompany.class, 1);
		session.getTransaction().commit();
		return company;
	}

	@Override
	public List<TCompany> findAllCompanys() {
		Session session = MySessionFactory.currentSession(1);
		session.beginTransaction();
		Query query =  session.createQuery("From TCompany");
		List<TCompany> cms = query.list();
		session.getTransaction().commit();
		return cms;
	}

}
